<?php
if ( $_SESSION['logged_in'] == FALSE ) redirect (base_url ());


/*
 * Modify or add a menu item
 * 
 */
echo '<div id="contentfull">';
echo '<div id="forms">';
echo '<a href="'.$baseurl.'index.php/menulist"><img src="'.$baseurl.'public/images/close.png" align="right" alt="close" border="0" /></a>';
$attributes = array('class' => 'manufrm', 'id' => 'manufrm', 'name' => 'areafrm');
$hidden = array('id' => $menud['id'], 'type' => $type );
echo form_open($baseurl."index.php/modmenu/".$menud['id'], $attributes, $hidden);
echo form_fieldset('<h2> '.$heading.' </h2>');
// var_dump($streets);


 ?>
<table>
    <tr>
        <td width="150px" >
<?php   echo form_label('Menu Name *', 'tname'); 
        //echo form_error('Name'); 
   if ($type == 'edit') {
        $namec = array('name' => 'tname', 
          'id' => 'tname',  
          'maxlength'   => '25',
          'value'       => $menud['name'],
          'style'       => 'width: 150px',
          'readonly' => TRUE  );
        
   } else {
       $namec = array('name' => 'tname', 
          'id' => 'tname',  
          'maxlength'   => '25',
          'value'       => $menud['name'],
          'style'       => 'width: 150px' );          
   }
?>  </td>
        <td width="200px" ><?php echo form_input($namec); echo '<br>'.form_error('tname');?>       </td>
        <td width="150px" ></td>
        <td width="200px" > </td>
    </tr>
    <tr>
        <td width="150px" >
<?php   echo form_label('URL *', 'url'); 
        //echo form_error('Name'); 
        $urlc = array('name' => 'url', 
               'id' => 'url',  
               'maxlength'   => '150',
               'value'       => $menud['url'],
              'style'       => 'width: 150px' ); ?>  </td>
        <td width="200px" ><?php echo form_input($urlc); echo '<br>'.form_error('url');?>       </td>
        <td width="150px" ></td>
        <td width="200px" > </td>
    </tr>
    
    <tr>
        <td> <?php echo form_label('Parent * ', 'parent');  $level = array('name' => 'parent', 'id' => 'parent' );
      
        // This chunk of code only shows the arears that are linked
       // var_dump($areas);
         $options = [];
         $options = array_merge($options, array('none' => 'Top Level Menu'));
         foreach($toplevel as $value)
        {
            $mid = $value['name'] ;
            $t = array($mid => $value['name']);
            $options = array_merge($options, $t); 
        }
        $selected = $menud['parent'];
        
?>      </td>
        <td> <?php echo form_dropdown('parent', $options, $selected); ?> </td>
    </tr>   
    
    <tr> 
      <td> <?php echo form_label('Roles * ', 'roles');  
         
        $level = array('name' => 'roles', 'id' => 'roles', 'value' => $menud['roles'], 'style' => 'width: 200px; height: 60px;');
        
        ?> </td>
      <td> <?php echo form_textarea($level); ?> </td>
   </tr>
   <tr> 
      <td> <?php echo form_label('Pages * ', 'pages');  
         
        $level = array('name' => 'pages', 'id' => 'pages', 'value' => $menud['pages'], 'style' => 'width: 200px; height: 60px;');
        
        ?> </td>
      <td> <?php echo form_textarea($level); ?> </td>
   </tr>
   <tr> 
      <td> <?php echo form_label('Tags * ', 'tags');  
         
        $level = array('name' => 'tags', 'id' => 'tags', 'value' => $menud['tags'], 'style' => 'width: 200px; height: 60px;');
        
        ?> </td>
      <td> <?php echo form_textarea($level); ?> </td>
   </tr>
   
   
   
   
   
   
       
    <tr>
        <td colspan="4" align="right" > <?php 
        echo form_submit('save', 'Save'); 
        echo form_submit('delete', 'Delete');
        echo form_reset('reset', 'Reset');?>  
   </tr>
</table>    
<?=form_fieldset_close()?>
<?=form_close(); ?>

</div> <!--content-->
</div> <!--login-->




    